home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d985.lha / NewIFF / Locale.ReadMe next >
Text File  |  1994-04-04  |  3KB  |  68 lines

  1. Adding localization
  2. ===================
  3.  
  4. These modules have some conditional localization code in the modules
  5. iffpstrings.c which is currently turned off.  The code is provided as a
  6. template for YOU if you wish to add localization to your IFF application.
  7.  
  8. The iffpstrings.h file and a blank translation file are created with
  9. the gencat script and CatComp localization tool. An iffp/iffp.cd catalog
  10. description file is generated but not used.
  11.  
  12. If you want to write a localized IFF application, take iffp.cd and
  13. iffpstrings.c, and make copies called yourapp.cd and yourappstrings.c
  14. (for example Wowpaint.cd and Wowpaintstrings.c).  Make a copy of
  15. the gencat script and edit the ".def" lines to make the basename
  16. and catalog name correct for your application (i.e. wowpaint).
  17.  
  18. Add your own strings to the end (or beginning) of yourapp.cd
  19. Then use CatComp (via your modified gencat script). This will create
  20. yourappstrings.h and a blank translation file yourapp.ct.
  21.  
  22. See CatComp.doc.  The current CatComp will be available on V39 disks
  23. for registered developers, and will soon be available in our public
  24. area on BIX (amiga.dev/listings).  We also plan to send it to Fred Fish.
  25.  
  26. Edit yourappstrings.c to have it use yourapp.catalog and include
  27. yourappstrings.h.  CatComp has many usage options including the
  28. ability to create a .o file for you.  I just use the array and
  29. have my own GetString function which you can see in iffpstrings.c.
  30. And turn on the conditional localization code in yourappstrings.c.
  31.  
  32. Your other modules that need to access strings can #define CATCOMP_NUMBERS
  33. and include yourappstrings.h to just gain access to the string ID numbers.
  34. You will probably also want to include a macro like the S(i) macro below
  35. for easy access of strings via their ID.
  36.  
  37. Your main module needs to OpenLibrary("locale.library",38) into LocaleBase,
  38. and must call OpenStrings() initially, and CloseStrings() (before CloseLibrary
  39. of LocaleBase) before exiting.  The OpenStrings/CloseStrings functions
  40. are in yourappstrings.c.   You will link with yourappstrings.c,
  41. not iffpstrings.c, and you will use yourappstrings.h, not iffpstrings.h.
  42.  
  43.  
  44. #define S(i)  GetString(i)
  45.  
  46. The above macro will allow you to easily retreive any of your
  47. strings during execution.  Examples:
  48.  
  49.  
  50. printf( S(MSG_GOODWORK) );
  51.  
  52. printf ("%s: %s\n", progname, S(MSG_COMPLETED));
  53.  
  54. MyNewWindow.Title = S(MSG_MYWINDOWTITLE);
  55.  
  56. etc.
  57.  
  58.  
  59. You can use the blank yourapp.ct file to have translations made
  60. for your strings.  Then use CatComp to turn the .ct file into
  61. a yourapp.catalog file for the translation language.
  62.  
  63. If locale.library and a yourapp.catalog (in a user's preferred language)
  64. have been opened by OpenStrings(), the S() macro will return a localized
  65. string to you.  Else, it will return the original string from
  66. yourpptrings.h.
  67.  
  68.